
<?
	 layout("/inc/win_layout.html",{title:sysTitle}){
    ?>


<div class="panel ">
	<div class="panel-body pan" style="height: 305px">
	<div class="form-body pal">
		<div class="row" style="margin-top:-15px; margin-bottom: 10px;">
			<div class="col-lg-6" style="width: 98%; float:left; margin-right:-20px; display:inline;">
				<label for="inputUsername" class="col-md-3 control-label">名称
					<span class='require' id="yonghu">*</span> </label>
				<div class="col-md-9">
					<div class="input-icon">
						<input id="title" type="text" class="form-control" />
					</div>
				</div>
			</div>
			<div class="col-lg-6" style="width: 98%; float:left; margin-right:-20px; display:inline;">
				<label for="inputUsername" class="col-md-3 control-label">url
					<span class='require'>*</span> </label>
				<div class="col-md-9">
					<div class="input-icon">
						<input id="url" type="text" class="form-control" />
					</div>
				</div>
			</div>
		<div class="col-lg-6" style="width: 98%; float:left; margin-right:-20px; display:inline;">
			<label for="inputUsername" class="col-md-3 control-label">描述
				<span class='require'></span> </label>
			<div class="col-md-9">
				<div class="input-icon">
					<textarea id="description"  rows="3" cols="20" class="form-control" ></textarea> 
				</div>
			</div>
		</div>
		<input id="id" type="hidden" class="form-control" />
	</div>
</div>
<?} ?>
<script>
	var id = window.parent.getId();
	var curr = window.parent.getCurr();
	$(function() {
		if (id != 0) {
			demo();
		}
	});
	
	function Page() {
		if ($.trim($("#title").val()).length < 1) {
			alert('名称不能为空！');
			return null;
		}
		if ($.trim($("#url").val()).length < 1) {
			alert('url不能为空！');
			return null;
		}
		$.ajax({
			type : "post",
			url : "addOrUploadLiveStream.do",
			data : {
				"id" : id,
				"description" : $("#description").val(),
				"title" : $("#title").val(),
				"url" : $("#url").val(),
			},
			dataType : "json",
			async : false,
			success : function(data) {
				var index = parent.layer.getFrameIndex(window.name);
				if(data[0].data == 'yes'){
					window.parent.demo(curr);
					parent.layer.msg('提交成功');
					parent.layer.close(index);
				}else{
					parent.layer.msg('提交失败！请检查数据是否正确！');
				}
			},
			error : function(data) {
				parent.layer.msg('提交失败！请检查数据是否正确！');
			}
		});
	}
	function demo() {
		$.getJSON('findLiveStreamList.do', {
			id : id
		//向服务端传的参数，此处只是演示
		}, function(res) {
			//此处仅仅是为了演示变化的内容
			$("#description").val(res[0].description);
			$("#id").val(res[0].id);
			$("#title").val(res[0].title);
			$("#url").val(res[0].url);
		});
	};
</script>


